package com.cxl.mapreduce._14index;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * @author joyson
 * @create 2019-06-27-下午5:51
 */
public class TwoIndexReducer extends Reducer<Text, Text, Text, Text> {
    Text v=new Text();
    @Override
    protected void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException {
//        atguigu  a.txt	3
//				 b.txt	2
//				 c.txt	2
//		atguigu	c.txt-->2	b.txt-->2	a.txt-->3
        StringBuilder builder = new StringBuilder();
        for (Text value : values) {
            builder.append(value.toString().replace("\t","-->")+"\t");
        }
        v.set(builder.toString());
        context.write(key,v);
    }
}
